import {
  get,
  post,
} from "./base_service"


/**
 * 房源专家接口
 *
 * allen  2021-08-02
 */

/**
 * 获取首页的专家列表
 */
const queryHomeExpertList = (page = 0, pageSize = 10, cityName) => {
  return new Promise((resolve, reject) => {
    get("/expert/home?page=" + page + "&pageSize=" + pageSize + "&cityName=" + cityName).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.msg)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}

/**
 * 获取所有的咨询师
 */
const queryAllExpertList = (page, pageSize, words, cityName) => {
  return new Promise((resolve, reject) => {
    get("/expert/list?page=" + page + "&pageSize=" + pageSize + "&words=" + words + "&cityName=" + cityName).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.msg)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}

/**
 * 根据房源查询报备对接专家
 * @param {*} houseNumber 
 */
const queryReportHouseExpert = (houseNumber) => {
  return new Promise((resolve, reject) => {
    get("/expert/house/docker", {
      houseNumber: houseNumber
    }).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.msg)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}

/**
 * 根据id查询专家详情
 * @param {*} id 
 */
const queryExpertDetailById = (id) => {
  return new Promise((resolve, reject) => {
    get("/expert/detail?id=" + id).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.msg)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}

/**
 * 更新自己的专家介绍
 * @param {*} talk 
 */
const updateMyExpertTalk = (talk) => {
  return new Promise((resolve, reject) => {
    get("/expert/update/talk?talk=" + talk).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.msg)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}



/**
 * 是否关闭首页展示
 */
const expertCloseRequest = () => {
  return new Promise((resolve, reject) => {
    get("/expert/close/view").then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.msg)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}




module.exports = {
  queryHomeExpertList,
  queryReportHouseExpert,
  queryAllExpertList,
  queryExpertDetailById,
  updateMyExpertTalk,
  expertCloseRequest
}

